﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace CoreLib
{
    /// <summary>
    /// 保存文件
    /// </summary>
    public class SaveFileClass
    {
        /// <summary>
        /// 保存二进制文件
        /// </summary>
        /// <param name="FullFileName"></param>
        /// <param name="TextAll"></param>
        /// <returns></returns>
        public static bool SaveASCIIFile(string FullFileName, List<string> TextAll)
        {
            if (File.Exists(FullFileName))
            {
                File.Delete(FullFileName);
            }
            try
            {
                FileStream fs = new FileStream(FullFileName, FileMode.CreateNew);
                fs.Close();
                StreamWriter sw = new StreamWriter(FullFileName, true, Encoding.Default);
                //该编码类型不会改变已有文件的编码类型
                foreach (string st in TextAll)
                {
                    sw.WriteLine(st);
                }
                sw.Close();
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}